////////

#if 1
#include <stdio.h>
#include <stdint.h>

#include <que_struct.h>


static int getRtcMaxCount(void);
static void entryItmU16Que(struct u16Queue *q,uint16_t e);
static void exitItmU16Que(u16Queue *q,uint16_t *e);

static void getItmU16Que(u16Queue *q,uint16_t i,uint16_t* v);
static int getLenU16Que(u16Queue *q);

static void entryItmU16Que(u16Queue *q,uint16_t e)
{
	if((q->rear + 1) % q->getQueCount() == q->front)
	{
			q->front = (q->front + 1) % q->getQueCount();
	}
	q->pData[q->rear] = e;
	q->rear = (q->rear + 1) % q->getQueCount();
}

static void exitItmU16Que(u16Queue *q,uint16_t *e)
{
	if(q->rear == q->front)
		return;
	*e = q->pData[q->front];
	q->front = (q->front + 1) % q->getQueCount();
}
static void getItmU16Que(u16Queue *q,uint16_t i,uint16_t* v)
{
	uint16_t len;
	if(q->rear == q->front)
		return;
	len = (q->rear - q->front + q->getQueCount()) % q->getQueCount();
	if(len <= i) return;
	*v = q->pData[(q->front+i)% q->getQueCount()];
}
static int getLenU16Que(u16Queue *q)
{
	return (q->rear - q->front + q->getQueCount()) % q->getQueCount();
}



//const int CRtcMaxSIZE=5;
#define CRtcMaxSIZE 5
static uint16_t RtcData[CRtcMaxSIZE];

static int getRtcMaxCount(void)
{
    return CRtcMaxSIZE;
}

static u16Queue RtcQue=
{
    //.count=CRtcMaxSIZE,
    .front=0,
    .rear=0,
    .getQueCount=getRtcMaxCount,
    .push_back=entryItmU16Que,
    .pop_front=exitItmU16Que,
    .get_index=getItmU16Que,
    .length=getLenU16Que,
    .pData=RtcData
};

u16Queue* getRtcQuePt(void)
{
    return &RtcQue;
}

#endif



